package com.xiaohao.communication.daoImpl;

import com.xiaohao.communication.bean.ExpertAndEmp;
import com.xiaohao.communication.bean.ExpertInfo;
import com.xiaohao.communication.bean.UsersBaseInfo;
import com.xiaohao.communication.dao.UserDetailInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

@Repository
public class UserDetailInfoDaoImpl implements UserDetailInfoDao {

    @Autowired
    MongoTemplate mongoTemplate;


    //发送验证码到手机，这里保存手机号    mongo单个字段修改
    // 进行单个修改
    @Override
    public void addPhone(int id,String phoneNumber) {

        Query query = new Query(Criteria.where("user_id").is(id));
        Update update = new Update();
        update.set("phoneNumber",phoneNumber);
        mongoTemplate.updateFirst(query,update, UsersBaseInfo.class);

    }

    //专家认证
    @Override
    public void addExpert(ExpertInfo expertInfo) {
        mongoTemplate.insert(expertInfo,"expertInfo");
    }

    //添加专家和从业者公用信息
    @Override
    public void addMailAgeCompanyAddressEmp(ExpertAndEmp expertAndEmp) {
        mongoTemplate.save(expertAndEmp);
    }


}
